<?php

/**
 * This is the model class for table "comments".
 *
 * The followings are the available columns in table 'comments':
 * @property string $coid
 * @property string $cid
 * @property string $created
 * @property string $author
 * @property string $authorId
 * @property string $ownerId
 * @property string $mail
 * @property string $url
 * @property string $ip
 * @property string $agent
 * @property string $text
 * @property string $type
 * @property string $status
 * @property string $parent
 */
class Comments extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Comments the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{comments}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('cid, created, authorId, ownerId, parent', 'length', 'max'=>10),
			array('author, mail, url, agent', 'length', 'max'=>200),
			array('ip', 'length', 'max'=>64),
			array('type, status', 'length', 'max'=>16),
			array('text', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('coid, cid, created, author, authorId, ownerId, mail, url, ip, agent, text, type, status, parent', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'coid' => 'Coid',
			'cid' => 'Cid',
			'created' => 'Created',
			'author' => 'Author',
			'authorId' => 'Author',
			'ownerId' => 'Owner',
			'mail' => 'Mail',
			'url' => 'Url',
			'ip' => 'Ip',
			'agent' => 'Agent',
			'text' => 'Text',
			'type' => 'Type',
			'status' => 'Status',
			'parent' => 'Parent',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('coid',$this->coid,true);
		$criteria->compare('cid',$this->cid,true);
		$criteria->compare('created',$this->created,true);
		$criteria->compare('author',$this->author,true);
		$criteria->compare('authorId',$this->authorId,true);
		$criteria->compare('ownerId',$this->ownerId,true);
		$criteria->compare('mail',$this->mail,true);
		$criteria->compare('url',$this->url,true);
		$criteria->compare('ip',$this->ip,true);
		$criteria->compare('agent',$this->agent,true);
		$criteria->compare('text',$this->text,true);
		$criteria->compare('type',$this->type,true);
		$criteria->compare('status',$this->status,true);
		$criteria->compare('parent',$this->parent,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}
